package com.example.h1nson.realphotography;

import android.hardware.camera2.params.StreamConfigurationMap;
import android.test.InstrumentationTestCase;

import com.example.h1nson.realphotography.asyncTask.CommentAsyTask;
import com.example.h1nson.realphotography.asyncTask.PhotoDetailAsynTask;
import com.example.h1nson.realphotography.config.ConfigURL;
import com.example.h1nson.realphotography.config.GetCurrentUser;
import com.example.h1nson.realphotography.entity.User;
import com.example.h1nson.realphotography.interface_photo.OnDataFinishedListener;
import com.example.h1nson.realphotography.util.HttpClientPost;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by H1nson on 2016/5/25.
 */
public class PhotoDetailTest extends InstrumentationTestCase {
    public void test(){
        User user = new User(1,"userName","email","password",
                "userInfo","userPreferAddress","userHead");
        GetCurrentUser.currentUser = user;

        JSONObject jsonObject = new JSONObject();
        String jsonReqStr =null;
        try {
            jsonObject.put("photoId", 1);
            jsonObject.put("curUserId", GetCurrentUser.currentUser.getUserId());
            jsonReqStr = jsonObject.toString();
        }catch (JSONException e){
            e.printStackTrace();
        }
        HttpClientPost post = new HttpClientPost(ConfigURL.detailPhotoURL,jsonReqStr);
        post.doPost();
        String jsonStr =  post.getJsonStrRes();
        try {
            JSONObject json = new JSONObject(jsonStr);
            String name = json.getString("ownerName");
            assertEquals("Hinson",name);
        }catch (JSONException e){
            e.printStackTrace();
        }



    }
}
